import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86138
 * Date: 2024-05-15
 * Time: 13:13
 */
public class May_15 {
    public static void main(String[] args) {
        int[][] array = new int[][]{{1,2},{3,4}};
        int[][] array2 = new int[2][];//Java中可以省略列，不可以省略行，动态初始化二维数组会使得列的值为NULL，所以要复制后才可以运行，否则报错
        array2[0] = new int[]{1,2};//必须完整地写上new int才可以对已经动态初始化的数组初始化
        array2[1] = new int[]{3,4};

        int[][] array3 = new int[2][];//不规则二维数组
        array3[0] = new int[3];
        array3[1] = new int[5];//动态初始化二维数组会使得列的值为NULL,会报错，但是在确定列后就NULL变为0了
        System.out.println(Arrays.deepToString(array3));


        int [] array9 = new int[]{5,4,8,9};
    }


    public static void main1(String[] args) {
        int[][] array1= {{1,2,3},{4,5,6}};
        /*for (int i = 0; i < array1.length; i++) {//array1.length是多少个一维数组，相当于是多少行
            for (int j = 0; j < array1[i].length; j++) {//array1[i].length是一行一维数组有多少个元素
                System.out.print(array1[i][j]+" ");
            }
        }*/
        for (int[] t:array1) {
            for (int x:t) {
                System.out.print(x+" ");
            }
        }
    }
}
